import axios from '@/utils/axios'

/**
 * 描述
 * @author LXBsmile
 * @date 2019-10-21
 * @param {Number} devId 设备id
 * @param {Number} rows page size
 * @param {Number} page page index
 * @returns {Array} 参数列表
 */
export function getParams(devId, rows, page) {
  const params = {
    deviceId: devId,
    rows: rows,
    page: page
  }
  return axios.get('fes/device/getCqname', { params }).then(res => {
    if (res.code === 1) {
      return res.data;
    } else {
      throw res.msg;
    }
  })
}

export function getHisData(params) {
  // const params = {
  //   paramId,
  //   interval,
  //   rows,
  //   page,
  //   startTime,
  //   endTime,
  //   variabletype
  // }
  return axios.get('plat/isp/queryHistoryData', { params }).then(res => {
    if (res.code === 1) {
      return res.data;
    } else {
      throw res.msg;
    }
  })
}

export function getTypes() {
  return axios.get('plat/device/type/all').then(res => {
    if (res.code === 1) return res.data;
    else throw res.msg;
  })
}

export function getTransformers(params) {
  return axios.get('plat/device/transformer/listPage', { params }).then(res => {
    if (res.code === 1) return res.data;
    else throw res.msg;
  })
}

export function saveTransformer(data) {
  return axios.post('plat/device/transformer/save', data).then(res => {
    if (res.code === 1) return true;
    else throw res.msg;
  })
}

export function deleteTransformer(pkid) {
  const params = { pkid }
  return axios.get('plat/device/transformer/delete', { params }).then(res => {
    if (res.code === 1) return;
    else throw res.msg;
  })
}

export function getHighDevs(params) {
  return axios.get('plat/device/highVol/listPage', { params }).then(res => {
    if (res.code === 1) return res.data;
    else throw res.msg;
  })
}

export function saveHighDev(data) {
  return axios.post('plat/device/highVol/save', data).then(res => {
    if (res.code === 1) return;
    else throw res.msg;
  })
}

export function deleteHighDev(pkid) {
  const params = { pkid }
  return axios.get('plat/device/highVol/delete', { params }).then(res => {
    if (res.code === 1) return;
    else throw res.msg;
  })
}

export function getLowDevs(params) {
  return axios.get('plat/device/lowVol/listPage', { params }).then(res => {
    if (res.code === 1) return res.data;
    else throw res.msg;
  })
}

export function saveLowDev(data) {
  return axios.post('plat/device/lowVol/save', data).then(res => {
    if (res.code === 1) return true;
    else throw res.msg;
  })
}

export function deleteLowDev(pkid) {
  const params = { pkid }
  return axios.get('plat/device/lowVol/delete', { params }).then(res => {
    if (res.code === 1) return;
    else throw res.msg;
  })
}

// export function getFrontDevs(pkid) {
//   const params = { pkid }
//   return axios.get('', { params }).then(res => {
//     if (res.code === 1) return res.data;
//     else throw res.msg;
//   })
// }

